package dyyx.guide.ser;

import java.io.Serializable;
import java.nio.ByteBuffer;

public class UserInfo implements Serializable {

	private static final long serialVersionUID = 1L;
	
	public int id;
	public String name;
	
	
	public byte[] toBytes(){
		ByteBuffer bf = ByteBuffer.allocate(1024);	
		bf.putInt(id);
		byte[]bytes = name.getBytes();
		int len = bytes.length;
		bf.putInt(len);
        bf.put(bytes);
		bf.flip();
		byte[]result = new byte[bf.remaining()];
		bf.get(result);	
		
		return result;
	}
	
	
}